<template>
  <div class="draw">
    <div class="content">
      <div class="content-tag">
        <div class="content-tag__message">
          <span class="content-tag__title">35kv母线</span>
          <span class="content-tag__summary"
            >总发电功率：{{
              megInfluxlineSystemDiagramData.power | noDataFormat
            }}</span
          >
        </div>
      </div>
      <div class="content-tip">
        <div class="content-tip__child is-child--1">
          <span>发电{{ statusDetails.fdNum | noDataFormat }}</span>
        </div>
        <div class="content-tip__child is-child--2">
          <span>限电{{ statusDetails.xdNum | noDataFormat }}</span>
        </div>
        <div class="content-tip__child is-child--3">
          <span>停运{{ statusDetails.tyNum | noDataFormat }}</span>
        </div>
        <div class="content-tip__child is-child--4">
          <span>检修{{ statusDetails.jxNum | noDataFormat }}</span>
        </div>
        <div class="content-tip__child is-child--5">
          <span>大风{{ statusDetails.dfNum | noDataFormat }}</span>
        </div>
        <div class="content-tip__child is-child--6">
          <span>待风{{ statusDetails.daifNum | noDataFormat }}</span>
        </div>
        <div class="content-tip__child is-child--7">
          <span>故障{{ statusDetails.gzNum | noDataFormat }}</span>
        </div>
        <div class="content-tip__child is-child--8">
          <span>无风{{ statusDetails.wfNum | noDataFormat }}</span>
        </div>
        <div class="content-tip__child is-child--9">
          <span>离线{{ statusDetails.lxNum | noDataFormat }}</span>
        </div>
      </div>
      <div v-if="section1.length > 0" class="section section-1">
        <div class="section-news">
          <div class="section-news__title">
            发电功率
          </div>
          <span class="section-news__label"
            >{{ lineArr[0].power | noDataFormat }}kW</span
          >
        </div>
        <div class="section-rect"></div>
        <div class="section-body">
          <div
            v-for="(item, index) in section1"
            :key="item.name + index"
            class="section-child"
            :class="`is-child--${item.type}`"
          >
            <div class="section-message">
              <span class="section-message__title">风速</span>
              <span class="section-message__label"
                >{{ item.windSpeed | noDataFormat }}m/s</span
              >
            </div>
            <div class="section-message">
              <span class="section-message__title ">发电功率</span>
              <span class="section-message__label"
                >{{ item.power | noDataFormat }}kW</span
              >
            </div>
          </div>
        </div>
      </div>
      <div v-if="section2.length > 0" class="section section-2">
        <div class="section-body">
          <div
            v-for="(item, index) in section2"
            :key="item.name + index"
            class="section-child"
            :class="`is-child--${item.type}`"
          >
            <div class="section-message">
              <span class="section-message__title">风速</span>
              <span class="section-message__label"
                >{{ item.windSpeed | noDataFormat }}m/s</span
              >
            </div>
            <div class="section-message">
              <span class="section-message__title ">发电功率</span>
              <span class="section-message__label"
                >{{ item.power | noDataFormat }}kW</span
              >
            </div>
          </div>
        </div>
      </div>
      <div v-if="lineArr.length > 1" class="section section-3">
        <div class="section-news">
          <div class="section-news__title">
            发电功率
          </div>
          <span class="section-news__label"
            >{{ lineArr[1].power | noDataFormat }}kW</span
          >
        </div>
        <div class="section-rect"></div>
        <div class="section-body">
          <div
            v-for="(item, index) in section3"
            :key="item.name + index"
            class="section-child"
            :class="`is-child--${item.type}`"
          >
            <div class="section-message">
              <span class="section-message__title">风速</span>
              <span class="section-message__label"
                >{{ item.windSpeed | noDataFormat }}m/s</span
              >
            </div>
            <div class="section-message">
              <span class="section-message__title ">发电功率</span>
              <span class="section-message__label"
                >{{ item.power | noDataFormat }}kW</span
              >
            </div>
          </div>
        </div>
      </div>
      <div v-if="lineArr.length > 1" class="section section-4">
        <div class="section-body">
          <div
            v-for="(item, index) in section4"
            :key="item.name + index"
            class="section-child"
            :class="`is-child--${item.type}`"
          >
            <div class="section-message">
              <span class="section-message__title">风速</span>
              <span class="section-message__label"
                >{{ item.windSpeed | noDataFormat }}m/s</span
              >
            </div>
            <div class="section-message">
              <span class="section-message__title ">发电功率</span>
              <span class="section-message__label"
                >{{ item.power | noDataFormat }}kW</span
              >
            </div>
          </div>
        </div>
      </div>
      <div class="content--none" v-if="showNone">
        <div class="none"></div>
      </div>
    </div>
  </div>
</template>
<script>
import {
  megInfluxlineSystemDiagram,
  windStatusSystemOverview
} from "@/api/scada";

export default {
  name: "draw",
  props: {},
  data() {
    return {
      megInfluxlineSystemDiagramData: {},
      lineArr: [],
      section1: [],
      section2: [],
      section3: [],
      section4: [],
      statusDetails: {}
    };
  },
  computed: {
    showNone() {
      const { section1, section2, lineArr } = this;
      return (
        section1.length === 0 && section2.length === 0 && lineArr.length === 0
      );
    }
  },
  created() {},
  mounted() {
    megInfluxlineSystemDiagram().then((res) => {
      if (res.code === 200 && res.result && res.result.length > 0) {
        this.lineArr = res.result;

        this.section1 = res.result[0].windVOS;
        this.section2 = this.section1.splice(4);
        this.section3 = res.result[1].windVOS || [];
        this.section4 = this.section1.splice(4);

        this.setType(this.section1);
        this.setType(this.section2);
        this.setType(this.section3);
        this.setType(this.section4);
      }
    });
    windStatusSystemOverview().then((res) => {
      if (res.code === 200) {
        this.statusDetails = res.result;
      }
    });
  },
  watch: {},
  methods: {
    setType(arr) {
      arr.forEach((item) => {
        if (item.fdStatus > 0) {
          item.type = 1;
        } else if (item.xdStatus > 0) {
          item.type = 2;
        } else if (item.tyStatus > 0) {
          item.type = 3;
        } else if (item.jxStatus > 0) {
          item.type = 4;
        } else if (item.dfStatus > 0) {
          item.type = 5;
        } else if (item.daifStatus > 0) {
          item.type = 6;
        } else if (item.gzStatus > 0) {
          item.type = 7;
        } else if (item.wfStatus > 0) {
          item.type = 8;
        } else {
          item.type = 9;
        }
      });
    }
  },
  components: {}
};
</script>

<style scoped lang="scss">
.draw {
  padding-top: 80px;
}

.content {
  position: relative;
  .content-tag {
    position: absolute;
    top: 0px;
    left: 0px;
    background-color: #369afe;
    width: 403px;
    height: 10px;
  }
  .content-tag__message {
    transform: translateY(-100%);
    text-align: center;
  }
  .content-tag__title {
    color: #333333;
    font-size: 16px;
    margin-right: 35px;
    line-height: 32px;
  }
  .content-tag__summary {
    color: #999999;
    line-height: 32px;
  }
  .content-tip {
    position: absolute;
    top: -5px;
    padding-left: 440px;
    width: 100%;
    display: flex;
    flex-wrap: wrap;
  }
  .content-tip__child {
    flex: none;
    padding-left: 24px;
    padding-right: 40px;
    margin-bottom: 20px;
    position: relative;
  }
  .content-tip__child::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
  }
  .content-tip__child.is-child--1::before {
    background-color: #4cb921;
  }
  .content-tip__child.is-child--2::before {
    background-color: #74d007;
  }
  .content-tip__child.is-child--3::before {
    background-color: #f14242;
  }
  .content-tip__child.is-child--4::before {
    background-color: #f8a507;
  }
  .content-tip__child.is-child--5::before {
    background-color: #369afe;
  }
  .content-tip__child.is-child--6::before {
    background-color: #1a3a81;
  }
  .content-tip__child.is-child--7::before {
    background-color: #ff4800;
  }
  .content-tip__child.is-child--8::before {
    background-color: #41b5b5;
  }
  .content-tip__child.is-child--9::before {
    background-color: #727272;
  }
}

.content--none {
  padding: 50px;
  .none {
    text-align: center;
    background-image: url("~@/assets/img/zwsj.png");
    background-position: center;
    background-repeat: no-repeat;
    color: #999;
    height: 500px;
    background-size: 190px;
  }
}

.section {
  margin-left: 140px;
  padding-left: 175px;
  position: relative;
  .section-rect {
    position: absolute;
    bottom: -17px;
    left: 130px;
    width: 40px;
    height: 29px;
    background-color: #369afe;
  }
  .section-news {
    position: absolute;
    bottom: 10px;
    left: 30px;
  }
  .section-news__title {
    color: #999999;
    font-size: 16px;
    line-height: 24px;
  }
  .section-news__label {
    color: #369afe;
    font-size: 16px;
  }
}

.section.section-1 {
  border-bottom: 5px solid #369afe;
  border-left: 5px solid #369afe;
  padding-top: 100px;
}

.section.section-2 {
  border-left: 5px solid #369afe;
  padding-bottom: 30px;
}

.section.section-3 {
  border-left: 5px solid #369afe;
  border-bottom: 5px solid #369afe;
  padding-top: 30px;
}

.section.section-4 {
  border-left: 5px solid transparent;
}

.section-body {
  padding: 10px;
  display: flex;
}

.section-child {
  padding: 0 20px;
  flex: 1;
  padding-top: 50px;
  position: relative;
}

.section-child::before {
  content: "";
  position: absolute;
  left: 40px;
  top: 0;
  display: inline-block;
  width: 46px;
  height: 42px;
  background-position: center;
  background-size: 100%;
  background-repeat: no-repeat;
  background-image: url("../../../../assets/img/windPower/3.png");
}

.section-message {
  line-height: 28px;
}

.section-message__title {
  margin-right: 10px;
  color: #9a9a9a;
}

.section-child.is-child--1::before {
  background-image: url("../../../../assets/img/windPower/32.png");
}

.section-child.is-child--1 {
  .section-message__label {
    color: #4cb922;
  }
}

.section-child.is-child--2::before {
  background-image: url("../../../../assets/img/windPower/31.png");
}

.section-child.is-child--2 {
  .section-message__label {
    color: #74d008;
  }
}

.section-child.is-child--3::before {
  background-image: url("../../../../assets/img/windPower/24.png");
}

.section-child.is-child--3 {
  .section-message__label {
    color: #f24242;
  }
}

.section-child.is-child--4::before {
  background-image: url("../../../../assets/img/windPower/25.png");
}

.section-child.is-child--4 {
  .section-message__label {
    color: #f8a508;
  }
}

.section-child.is-child--5::before {
  background-image: url("../../../../assets/img/windPower/26.png");
}

.section-child.is-child--5 {
  .section-message__label {
    color: #369afe;
  }
}

.section-child.is-child--6::before {
  background-image: url("../../../../assets/img/windPower/27.png");
}

.section-child.is-child--6 {
  .section-message__label {
    color: #1a3a82;
  }
}

.section-child.is-child--7::before {
  background-image: url("../../../../assets/img/windPower/28.png");
}

.section-child.is-child--7 {
  .section-message__label {
    color: #ff4800;
  }
}

.section-child.is-child--8::before {
  background-image: url("../../../../assets/img/windPower/29.png");
}

.section-child.is-child--8 {
  .section-message__label {
    color: #42b6b6;
  }
}

.section-child.is-child--9::before {
  background-image: url("../../../../assets/img/windPower/30.png");
}

.section-child.is-child--9 {
  .section-message__label {
    color: #727272;
  }
}
</style>
